package javabase.schoolwork.day6_10;

/**
 * @author fance
 * @date 2018/6/10 14:37
 */
class T implements Runnable {
    private volatile boolean flag = true;

    @Override
    public void run() {
        int i = 0;
        while (flag) {
            System.out.println(Thread.currentThread().getName() +
            " i = " + (i++));
        }
    }
    public void stop() {
        flag = false;
    }
}
public class StopDemo {
    public static void main(String[] args) throws InterruptedException {
        T t = new T();
        Thread thread = new Thread(t);
        thread.start();
        Thread.sleep(10);
        t.stop();

    }
}
